package com.jdk.demo.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class TimeClient {

	public static void main(String[] args) {
		int port = 8080;
		Socket socket = null;
		InputStream in = null;
		OutputStream out = null;
		try{
			socket = new Socket("192.168.1.105", port);

			out = socket.getOutputStream();
			out.write("QUERY TIME ORDER".getBytes());
			out.flush();
			System.out.println("Send order 2 server successd.");

			in = socket.getInputStream();
			byte[] b = new byte[65535];
			in.read(b);
			System.out.println(new String(b));
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try{
				if(out != null){
					out.close();
				}
				if(in != null){
					in.close();
				}
				if(socket != null){
					socket.close();
				}
			}catch(IOException e){
				e.printStackTrace();
			}
		}
	}

}
